package com.forecasting.utility;

//Utility implementation it as a Singleton this week.
import java.io.Serializable;
import java.text.*;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;

public class Utility implements Serializable{

	static public double getFactorial(int num){
		 double fact = 1;
		//calculate a numbers factorial
		for(int i = num; i >= 1; i--){
			fact = fact * i;
		}
		return fact;
	}
	//helps trims digit, pass the number with amount of decimals to keep
	static public double formatDecimal(double num,int num_decimals){
		NumberFormat numf = NumberFormat.getInstance(Locale.ENGLISH);
		
		numf.setMaximumFractionDigits(num_decimals);
		num = Double.parseDouble(numf.format(num));
		
		return num;
	}
}
